package idcard;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class IDCardInfo {
    private String name = "";
    private String sex = "";
    private String nation = "";
    private String bornYear = "";
    private String bornMonth = "";
    private String bornDay = "";
    private String addr = "";
    private String idNo = "";
    private String expDate = "";
    private String issuingAuthority = "";
    private String addr1 = "";
    private String addr2 = "";


    public String getSex() {
        Integer sexNum=Integer.valueOf(idNo.substring(16,17));
        return sexNum%2!=0?"男":"女";
    }

    public String getBornYear() {
        bornYear=idNo.substring(6,10);
        return bornYear;
    }

    public String getBornMonth() {
        bornMonth=idNo.substring(10,12);
        return String.valueOf(Integer.valueOf(bornMonth));
    }

    public String getBornDay() {
        bornDay=idNo.substring(12,14);
        return String.valueOf(Integer.valueOf(bornDay));
    }

    public String getAddr1() {
        addr1 = addr.length() > 11 ?
                addr.substring(0,11) : "";
        return addr1;
    }

    public String getAddr2() {
        addr2 = addr.length() > 11 ?
                addr.substring(11) : "";
        return addr2;
    }
}
